package com.ate.testday02.net;

import com.ate.testday02.Common;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @author Ate
 * @description:
 * @date :2020/11/11 8:15
 */
public class MRetrofit {
    private static MRetrofit instance;
    private Retrofit retrofit;
    private MRetrofit(){}
    public static MRetrofit getInstance(){
        if (instance==null){
            instance = new MRetrofit();
        }
        return instance;
    }
    public void retrofit(){
        HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
        httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client  =  new OkHttpClient.Builder().addNetworkInterceptor(httpLoggingInterceptor).build();

        retrofit = new Retrofit.Builder()
                .baseUrl(Common.HOST)
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }
    public void  goObservable(){
        retrofit.create(RetrofitApi.class).cctv();
    }
}
